{% extends "../base.html" %}

{% block title %}新規作成{% endblock %}

{% block css %}
<link type="text/css" rel="stylesheet" href="/css/new/index.css" />
{% endblock %}

{% block content %}
<h2>新規作成</h2>

{% if errors.other %}
<div class="error">{{ errors.other }}</div>
{% endif %}
{{ test }}

<form action="/new/post" method="post" id="new-pigeon-form">
<input type="hidden" id="draft" name="draft" value="0" />
<input type="hidden" id="id" name="id" value="{{ pigeon.id }}" />
<input type="hidden" id="create_from" name="create_from" value="{{ pigeon.create_from.key.id }}" />
    <div id="importance-row">
        <label for="importance">重要度:</label>
        <select id="importance" name="importance">
        {% for row in importances %}
            <option value="{{ row.0|escape }}"{% ifequal pigeon.importance row.0 %} selected{% endifequal %}>{{ row.1|escape }}</option>
        {% endfor %}
        </select>
        {% if errors.importance %}
        <span class="error">{{ errors.importance }}</span>
        {% endif %}
    </div>
    <div id="info-mail-row">
        <label>通知:</label>
        <input type="checkbox" id="send_info" name="send_info" value="1"{% if pigeon.send_info %} checked{% endif %} /><label for="send_info">メール通知</label>
        {% if errors.send_info %}
        <span class="error">{{ errors.send_info }}</span>
        {% endif %}
        <input type="checkbox" id="read_info" name="read_info" value="1"{% if pigeon.read_info %} checked{% endif %} /><label for="read_info">閲覧通知</label>
        {% if errors.read_info %}
        <span class="error">{{ errors.read_info }}</span>
        {% endif %}
    </div>
    <div id="to-row">
        <label for="to">宛先:</label>
        <input type="text" id="to" name="to" value="{{ pigeon.to|escape }}" />
        {% if errors.to %}
        <span class="error">{{ errors.to }}</span>
        {% endif %}
    </div>
    <div id="subject-row">
        <label for="subject">件名:</label>
        <input type="text" id="subject" name="subject" value="{{ pigeon.subject|escape }}" />
        {% if errors.subject %}
        <span class="error">{{ errors.subject }}</span>
        {% endif %}
    </div>
    <div id="body-row">
        <textarea name="body" id="body">{{ pigeon.body|escape }}</textarea>
        {% if errors.body %}
        <span class="error">{{ errors.body }}</span>
        {% endif %}
    </div>
    <div id="submit-row">
        <input type="submit" id="submit-button" value="送信" />
        <input type="button" id="draft-button" value="下書き" />
        {% ifequal pigeon.status 'Draft' %}
        <input type="button" id="delete-button" value="削除" />
        {% endifequal %}
    </div>
</form>
{% endblock %}

{% block js %}
<script src="/js/new/index.js" type="text/javascript"></script>
{% endblock %}
